<%@ page language="java"  pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>沈阳外卖网</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Bootstrap -->
<link href="publicui/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen" />
<!--[if lt IE 9]>
  <script src="public/js/html5shiv.js"></script>
<![endif]-->
<!-- application  -->
<link href="css/head.css" rel="stylesheet" />
<link href="css/foot.css" rel="stylesheet" />
<link href="css/address.css" rel="stylesheet" />

</head>

<body >

<!-----nav-->
<div class="head">
  <s:action name="top" executeResult="true"></s:action>
</div>
<!---/nav   --> 

<!---/body   -->
<div class="content" > 
<!--   content  -->
	
<ul class="breadcrumb">
	<li>
		<h1>
			地址管理
		</h1>
	</li>
</ul>

<div class="wash-paper clearfix" id="profile">
	<s:include value="left.action?urlType=8"></s:include>
	<div class="main-content">

		<div class="content-header">
			<h2>
				管理我的地址
			</h2>
		</div>

		<div class="content-inner profile-address">
			<h3>
				已经保存的送餐地址
			</h3>
			<s:if test="list!=null">
			<table class="address-table table table-bordered">
				<thead>
					<tr>
						<th class="col-address">
							地址
						</th>
						<th class="col-phone">
							联系人
						</th>
						<th class="col-phone">
							联系电话
						</th>
						<th class="col-phone-bk">
							备选电话
						</th>
						<th class="col-action">
							操作
						</th>
					</tr>
				</thead>
				<s:iterator id="l" value="%{list}">
				<tbody>
					<tr class="stable_address">
						<td class="col-address">
							<s:property value="#l.address"/>
						</td>
						<td class="col-phone">
							<s:property value="#l.linkman"/>
						</td>
						<td class="col-phone">
							<s:property value="#l.phone"/>
						</td>
						<td class="col-phone-bk">
							<s:property value="#l.back_phone"/>
						</td>
						<td class="col-action">
							<s:if test="#l.isDefault==1"><span>默认地址</span> |</s:if>
							<s:if test="#l.isDefault==0">
								<a href="address.action?action=updateIsDefault&id=<s:property value="#l.id"/>"><span>设为默认</span> |</a>
							</s:if>
							
							<a href="address.action?action=content&id=<s:property value="#l.id"/>">编辑</a> |
							<a href="javascript:del('<s:property value="#l.id"/>')">删除</a>
						</td>
					</tr>
				</tbody>
				</s:iterator>
			</table>
			</s:if>
			<h3>
				新增/编辑送餐地址<s:property value="error"/>
			</h3>
			<s:if test="addr!=null">
			<form method="post" action="address.action" id="myform">
				<input type="hidden" name="action" value="update"/>
				<input type="hidden" name="id" value="<s:property value="addr.id"/>"/>
				<fieldset>
					<div class="control-group">
						<label class="control-label" for="address[address]">
							<span class="required">*</span>详细地址
						</label>
						<div class="controls">
							<input type="text" name="address" id="address" maxlength="200" class="span4" value="<s:property value="addr.address"/>"/>
							<p class="help-block">
								(请填详细一点)
							</p>
						</div>
						<!--end input-->
					</div>
					<!--end clearfix-->
					<div class="control-group">
						<label class="control-label" for="address[address]">
							<span class="required">*</span>联系人
						</label>
						<div class="controls">
							<input type="text" name="linkman" id="linkman" maxlength="20" class="span4" value="<s:property value="addr.linkman"/>"/>
							<p class="help-block">
								(请填详细一点)
							</p>
						</div>
						<!--end input-->
					</div>
					
					<div class="control-group">
						<label class="control-label" for="address[phone]">
							<span class="required">*</span>联系电话
						</label>
						<div class="controls">
							<input type="text" name="phone" id="phone" maxlength="20" class="span4" value="<s:property value="addr.phone"/>"/>
							<p class="help-block">
								(外卖到时将以该电话通知您)
							</p>
						</div>
						<!--end input-->
					</div>
					<!--end clearfix-->

					<div class="control-group">
						<label class="control-label" for="address[phone]">
							备选电话
						</label>
						<div class="controls">
							<input type="text" name="backPhone" id="backPhone" maxlength="20" class="span4" value="<s:property value="addr.backPhone"/>"/>
							<p class="help-block">
								(为方便送餐员联系，请再留一个备用电话)
							</p>
						</div>
						<!--end input-->
					</div>
					<!--end clearfix-->

					<div class="form-actions">
						<button type="button" id="add_address_submit" class="btn btn-warning" onclick="VF_regflag();">保存</button>
					</div>
				</fieldset>

			</form>
			</s:if>
		</div>

	</div>
</div>
	
<!--   /content  -->
  <s:action name="foot" executeResult="true"></s:action>
</div>
<!--  alert div start---->
<div id="copy_dlg_restaurant"  class="restaurant-hover-dlg right hide" >
  <div class="wrapper dark_shadow">
    <div class="callout_tip"></div>
    <div class="detail"> </div>
  </div>
</div>
<!--  alert div  end ---->

<!---/body   --> 


<script src="publicui/js/jquery-1.8.3.js"></script> 
<script src="publicui/jquery-ui/js/jquery-ui-1.9.2.custom.js"></script> 
<script src="publicui/bootstrap/js/bootstrap.min.js"></script> 
<script src="js/head.js"></script> 
<script language="JavaScript" type="text/javascript">
<!--
function VF_regflag(){
	var address = $('#address').val();
	var linkman = $('#linkman').val();
	var phone = $('#phone').val();
	var notnull=true;
	if(address==""){
		alert("请填写地址");
		notnull=false;
	}
	else if(linkman==""){
		alert("请填写联系人");
		notnull=false;
	}
	else if(phone==""){
		alert("请填写联系电话");
		notnull=false;
	}
	if(notnull){
		$('#myform').submit();
	}
}
function del(id){
	var reg=window.confirm("你确定要删除吗？");
	if(reg){
		window.location.href="address.action?action=remove&id="+id;
	}
}
-->
</script>
<s:if test="error!=null&&error!=''">
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">提示</h3>
  </div>
  <div class="modal-body">
    <p><s:fielderror><s:param>error</s:param></s:fielderror></p>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
   <!-- <button class="btn btn-primary">确定 </button>   -->
  </div>
</div>
<script type="text/javascript"  >
$('#myModal').modal();
</script>
</s:if>
</body> 
</html>
